home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_bas
/
pbc32.zip
/
PBC$BAS.ZIP
/
FILESORT.BAS
< prev
next >
Wrap
BASIC Source File
|
1996-04-10
|
2KB
|
61 lines
' +----------------------------------------------------------------------+
' | |
' | PBClone (C) Copyright 1996 Charon Software, All Rights Reserved |
' | |
' +----------------------------------------------------------------------+
TYPE FileName
Arf AS STRING * 12 ' because TYPE is still pretty brain-dead
END TYPE
TYPE Partition
Lft AS INTEGER
Rht AS INTEGER
END TYPE
SUB FileSort (Array() AS FileName, Elements%)
DIM x AS STRING * 12
DIM SortStack(1 TO 16) AS Partition
S% = 1
SortStack(1).Lft = 1
SortStack(1).Rht = Elements%
DO
L% = SortStack(S%).Lft
R% = SortStack(S%).Rht
S% = S% - 1
DO
i% = L%
j% = R%
x = Array((L% + R%) \ 2).Arf
DO
WHILE Array(i%).Arf < x
i% = i% + 1
WEND
WHILE x < Array(j%).Arf
j% = j% - 1
WEND
IF i% <= j% THEN
SWAP Array(i%), Array(j%)
i% = i% + 1
j% = j% - 1
END IF
LOOP UNTIL i% > j%
IF j% - L% < R% - i% THEN
IF i% < R% THEN
S% = S% + 1
SortStack(S%).Lft = i%
SortStack(S%).Rht = R%
END IF
R% = j%
ELSE
IF L% < j% THEN
S% = S% + 1
SortStack(S%).Lft = L%
SortStack(S%).Rht = j%
END IF
L% = i%
END IF
LOOP UNTIL L% >= R%
LOOP WHILE S%
END SUB